<?php
use common\components\widgets\Datetimepicker;
use common\components\helpers\Fun;
use common\components\extenders\MenuManage;
use doumiaoduo\layer\LayerConfirmWidget;
use doumiaoduo\layer\LayerIframeWidget;

LayerConfirmWidget::widget();
LayerIframeWidget::widget();
use yii\helpers\Html;
Datetimepicker::widget(['flag'=>'timepicker']);
Datetimepicker::widget(['timepicker' => 'true','datepicker'=>'false','format'=>'H:i','step'=>'5']);
?>
<div class="yx-cnt-box yx-radius2">
    <div class="yx-praise-box">
        <div class="yx-search-class">
            <h3 class="yx-menubar yx-noborder">搜索课程班级：</h3>
            <div class="yx-praise-box yx-radius2 ">
                <div id="search-area" class="yx-bgf7f7f7 yx-radius5 zx-mg yx-function2 yx-pr0">
                    <?= Html::beginForm(Fun::url(['classmanage/index']), 'get', ['enctype' => 'multipart/form-data']) ?>
                    <?= \common\components\helpers\Search::textInput('teacher', \Yii::$app->request->get('teacher'), ['label'=>'教师姓名','class' => 'yx-width150 zx-lh24 yx-ml6']); ?>
                    <?= \common\components\helpers\Search::textInput('course', \Yii::$app->request->get('course'), ['label'=>'课程名称','class' => 'yx-width150 zx-lh24 yx-ml6']); ?>
                    <?= \common\components\helpers\Search::textInput('classroom', \Yii::$app->request->get('classroom'), ['label'=>'教室名称','class' => 'yx-input-text zx-width150 yx-ml6']); ?>
                    <?= \common\components\helpers\Search::textInput('mechanic', \Yii::$app->request->get('mechanic'), ['label'=>'机构','class' => 'yx-input-text zx-width150 yx-ml6']); ?>
                    <?= \common\components\helpers\Search::dropDownList('status', \Yii::$app->request->get('status'), [null=>'请选择',0=>'未开班',1=>'已开班',2=>'已结课'],['label'=>'状态','class' => 'diy_select_txt','promote'=>'请选择']); ?>
                    <?= \common\components\helpers\Search::dropDownList('cate', \Yii::$app->request->get('cate'), $cate,['label'=>'课程分类','class' => 'diy_select_txt','promote'=>'请选择']); ?>
                    <?= \common\components\helpers\Search::textInput('opentime', \Yii::$app->request->get('opentime'), ['label'=>'开班日期','class' => 'timepicker yx-input-text zx-width150 yx-ml6']); ?>
                    <?= \common\components\helpers\Search::textInput('start_time', \Yii::$app->request->get('start_time'), ['label'=>'开始时间','class' => 'search datetimepicker yx-width150 zx-lh24 yx-ml6']); ?>
                    <?= \common\components\helpers\Search::submitButton('搜索', ['id'=>'search-handle','class'=>"yx-search yx-radius2"]); ?>
                    <?php Html::endForm() ?>
                </div>
        </div>
        <div class="yx-class-box">
            <div class="tab-content">
                <div class="tab-pane active" id="class11">
                   <?php if($data):?>
                       <?php foreach($data as $item):?>
                            <div class="yx-class-list yx-radius2 yx-floatl">
                                <img src="<?=$item['avatar']?>" class="yx-border1 img-circle" width="73" height="73">
                                <ul>
                                    <li>课程名称：<?=$item['course']?></li>
                                    <li>机构名称：<?=$item['mechanic_name']?></li>
                                    <li>教师姓名：<?=$item['teacher']?></li>
                                    <li>教室名称：<?=$item['classroom_name']?></li>
                                    <li>开班人数：<?=$item['opening_number']?>人</li>
                                    <li>报名人数：<?=$item['COUNT(id)']?>人</li>
                                    <li>最大人数：<?=$item['max_number']?>人</li>
                                    <li>上课时间：<?=$item['class_day']?></li>
                                    <li>开课时间：<?= ($item['opentime'] == null) ? '未开课' : \Yii::$app->formatter->asDatetime($item['opentime']) ?></li>
                                    <li>状态：<?php
                                       switch($item['status']) {
                                           case 0:
                                               echo '未开课';
                                               break;
                                           case 1:
                                               echo '已开课';
                                               break;
                                           case 2:
                                               echo '已结束';
                                               break;
                                       }
                                        ?></li>
                                </ul>

                                <?php if ($item['status'] == 0) {?>
                                    <?php if($item['is_open'] == 1):?>
                                        <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('classmanage','open',false,['rel'=>'dialog-show-iframe','class' => 'btn yx-classmagage-about yx-class-begin yx-bg67dcd6 yx-radius2','data'=>['id'=>$item['id'],'name'=>'开班']]);?>
                                    <?php endif;?>
                                    <?php if($item['COUNT(id)'] == 0){?>
                                        <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('classmanage','delete',false,['rel'=>'record_item_confirm','class' => 'btn yx-classmagage-about yx-width47 yx-bgb5b5b5 yx-radius2 yx-mr0','data'=>['id'=>$item['id'],'name'=>'删除','message'=>'确定要删除么？']]);?>
                                    <?php }else{ ?>
                                        <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('classmanage','details',true,['rel'=>'','class' => 'btn yx-classmagage-about yx-width47 yx-bgfbc74f yx-radius2','data'=>['id'=>$item['id'],'name'=>'学员列表']]);?>
                                    <?php } ?>
                                <?php } else { ?>
                                    <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('classmanage','details',true,['rel'=>'','class' => 'btn yx-classmagage-about yx-width47 yx-bgfbc74f yx-radius2','data'=>['id'=>$item['id'],'name'=>'学员列表']]);?>
                                    <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('classmanage','lesson',false,['rel'=>'dialog-show-iframe','class' => 'btn yx-classmagage-about yx-width47 yx-bgfbc74f yx-radius2 yx-mr0','data'=>['id'=>$item['id'],'name'=>'课时详情']]);?>
                                    <?php if($item['status'] == 1 && ($item['end_time'] != null && time() > $item['end_time'] )):?>
                                        <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('classmanage','endcourse',false,['rel'=>'record_item_confirm','class' => 'btn yx-classmagage-about yx-width47 yx-bgfbc74f yx-radius2','data'=>['id'=>$item['id'],'name'=>'结课','message'=>'确定课程已结束么？']]);?>
                                    <?php endif;?>
                                <?php } ?>
                            </div>
                       <?php endforeach;?>
                    <?php endif;?>

                    <div class="yx-clear"></div>
                </div>
                <div style="text-align: right"><?= common\components\widgets\GoPager::widget(['pagination' => $pages]) ?></div>
            </div>
        </div>
    </div>
</div>